var Fly=require("../lib/fly-wx") //wx.js为您下载的源码文件
var fly=new Fly(); //创建fly实例
var {BASE,ID,KEY} = require('../config/index')

//添加拦截器
fly.interceptors.request.use((config,promise)=>{
    //给所有请求添加自定义header
    return config;
})
let statusList = {
    '200':'操作成功',
    '201':'操作成功',
    '400':'操作失败',
}
//响应拦截器
fly.interceptors.response.use((response)=>{
    console.log('响应拦截器',response);
    let {status} = response
    wx.showToast({
      title: statusList[status],
      icon:'none'
    })
    return response;
})
//配置请求基地址
fly.config.baseURL = BASE+'/1.1'
fly.config.headers = {
    "X-LC-Id": ID,
    "X-LC-Key": KEY,
    "Content-Type": "application/json"
}

module.exports = fly